﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.IO;
using System.Web;

namespace V5_Common {
    public class HtmlHelper {
        /// <summary>
        /// 加载用户控件
        /// </summary>
        /// <param name="pathName"></param>
        /// <returns></returns>
        public static string Include(string pathName) {
            try {
                System.Web.UI.Page page = new System.Web.UI.Page();
                UserControl ctl = (UserControl)page.LoadControl(pathName);
                page.Controls.Add(ctl);
                StringWriter writer = new StringWriter();
                HttpContext.Current.Server.Execute(page, writer, true);
                return writer.ToString();
            }
            catch (Exception ex) { return pathName + "加载失败!" + ex.Message + ex.InnerException; }
        }
    }
}
